
#include "weapon.h"
#include "config.h"
weapon::weapon()
{
    //资源加载
    m_weapon1.load(WEAPON_PATH1);
    m_weapon2.load(WEAPON_PATH2);

    m_x4=0;
    m_y4=0;
    m_x5=0;
    m_y5=0;
    m_free4=true;
    m_free5=true;

    m_speed=WEAPON_SPEED;
    m_rect4.setWidth(m_weapon1.width());
    m_rect4.setHeight(m_weapon1.height());
    m_rect4.moveTo(m_x4,m_y4);
    m_rect5.setWidth(m_weapon2.width());
    m_rect5.setHeight(m_weapon2.height());
    m_rect5.moveTo(m_x5,m_y5);
}

void weapon::updatePosition()
{
    if(m_free4)
    {
        return;


    }
    m_y4+=m_speed;
    m_rect4.moveTo(m_x4,m_y4);

    if(m_free5)
    {
        return;


    }
    m_y5+=m_speed;
    m_rect5.moveTo(m_x5,m_y5);



    //超出处理

    if(m_y4>=GAME_HEIGHT+m_rect4.height())
    {
        m_free4=true;
    }
    if(m_y5>=GAME_HEIGHT+m_rect5.height())
    {
        m_free5=true;
    }



}
